﻿Imports Microsoft.TeamFoundation.Client
Imports Microsoft.TeamFoundation.WorkItemTracking.Client

Public Class SfTSSprints
  Private Sub New()

  End Sub

  Public Shared Function Sprints(ByVal TFSServerName As String, ByVal TFSProjectName As String) As List(Of String)
    Dim sprintlist As New List(Of String)
    Dim tfsServer As TeamFoundationServer = TeamFoundationServerFactory.GetServer(My.Settings.TFSServerName)
    tfsServer.Authenticate()

    Dim wits As WorkItemStore = New WorkItemStore(My.Settings.TFSServerName)

    Dim sprint As WorkItemCollection = wits.Query("SELECT " & My.Settings.WISelectColumnsSprint & " FROM WorkItems WHERE [System.TeamProject] = '" & TFSProjectName & "' AND [System.WorkItemType]='Sprint'")

    For Each wi As WorkItem In sprint
      If sprintlist.Contains(wi.Fields("System.IterationPath").Value.ToString()) = False Then
        sprintlist.Add(wi.Fields("System.IterationPath").Value.ToString())
      End If


    Next
    Return sprintlist

  End Function
End Class
